package 双指针;

/**
 * @author 帅小伙
 * @date 2021/12/29
 * @description
 */
public class Demo02JZ81奇数在偶数前 {

    public int[] reOrderArrayTwo (int[] array) {
        // write code here
        int l = 0,r = array.length-1;


        while(l < r){
            while(array[l]%2==1){
                l++;
            }
            while(array[r]%2==0){
                r--;
            }
            if(l<r){
                swap(array,l,r);
                l++;
                r--;
            }


        }
        return array;



    }

    void swap(int[] array,int i,int j){
        int t = array[i];
        array[i] = array[j];
        array[j] = t;
    }
}
